package cn.edu.zzuli.wechat.user.mapper;

import cn.edu.zzuli.model.entity.RunOrder;
import cn.edu.zzuli.model.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    //查询用户的积分余额
    @Select("select wealth from user where uid = #{uid}")
    Double getUserWealth(Integer uid);

    //查询用户的信誉积分
    @Select("select credit from user where uid = #{uid}")
    Integer getUserCredit(Integer uid);

    //改变用户积分
    @Select("update user set wealth = wealth + #{bounty} where uid = #{uid}")
    void updateWealth(@Param("uid") Integer uid, @Param("bounty") Double bounty);

    //修改用户信誉积分
    @Update("update user set credit = credit - 5 where uid = #{uid}")
    void updateCredit(Integer uid);
}
